package thread_pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/5/19
 * Time:21:12
 * 根据当前工作环境来创建线程池
 **/
public class PoolDemo9 {
    public static void main(String[] args) {
        //根据当前工作环境来创建线程池
        ExecutorService service = Executors.newWorkStealingPool();
        for (int i = 0; i < 100; i++) {

            service.execute(new Runnable() {
                @Override
                public void run() {
                    System.out.println("线程名称：" + Thread.currentThread().getName());
                }
            });
        }
        //等待异步线程池执行完成（根据线程池的终止状态）
        while(!service.isTerminated()){

        }
    }
}
